package com.zyh.scs.admin.utils.jd;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HexFormat;

/**
 * desc:
 *
 * @author hwh
 */
public class ShaUtil {

    public static String encrypt(String strSrc, String encName) {
        MessageDigest md;
        byte[] bt;

        bt = strSrc.getBytes(StandardCharsets.UTF_8);

        try {
            if(encName == null || encName.isEmpty()) {
                encName = "SHA-256";
            }
            md = MessageDigest.getInstance(encName);
            md.update(bt);
            return HexFormat.of().formatHex(md.digest());
        } catch (NoSuchAlgorithmException var7) {
            return null;
        }
    }
}
